from langgraph.graph import StateGraph,START,END

def node_a(state):
    return {"x":state["x"]+1}

def node_b(state):
    return {"x":state["x"]+1}

def node_c(state):
    return {"x":state["x"]-2}

def routing_function(state):
    if state["x"] == 10:
        return True
    else:
        return False

builder = StateGraph(dict)

builder.add_node("node_a",node_a)
builder.add_node("node_b",node_b)
builder.add_node("node_c",node_c)

builder.set_entry_point("node_a")
builder.add_conditional_edges("node_a",routing_function,{True:"node_b",False:"node_c"})
builder.add_edge("node_b",END)
builder.add_edge("node_c",END)

graph = builder.compile()
resp = graph.invoke({"x":10})
print(resp)